package addslashes

import "bytes"

// Quote string with slashes
// https://www.php.net/manual/en/function.addslashes.php
func Do(str string) string {
	if len(str) == 0 {
		return ""
	}
	buf := bytes.NewBuffer([]byte{})
	for _, char := range str {
		switch char {
		case '\'', '"', '\\':
			buf.WriteRune('\\')
		}
		buf.WriteRune(char)
	}
	return buf.String()
}
